import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'
import { join } from "path";
import reactRefresh from "@vitejs/plugin-react-refresh";
import optimizer from 'vite-plugin-optimizer'
// # 控制台输出
// 这里千万不要使用@，因为这里还不能识别配置文件系统路径别名
import vitePluginStart from './src/plugin/vitePluginStart'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react(),
    reactRefresh(),
    vitePluginStart(),
    optimizer({
      child_process: () => ({
        find: /^(node:)?child_process$/,
        code: `const child_process = import.meta.glob('child_process');export { child_process as default }`
      })
    })],//插件
  //路径别名
  resolve: {
    alias: {
      '@': join(__dirname, "src"),
      '@public': join(__dirname, "public"),
      '@assets': join(__dirname, 'src/assets'),
    }
  },
  server: {
    port: 5173,
    proxy: {
      "/api": {
        target: "",
        changeOrigin: true,
        cookieDomainRewrite: "",
        secure: false,
      },
    },
  },
  css: {
    preprocessorOptions: {
      less: {}
    }
  }
})
